ref- https://plot.ly/python/choropleth-maps/#choropleth-map-with-plotlyexpress
import pandas as pd
import plotly.graph_objects as go
df = pd.read_csv('data/2011_US_AGRI_Exports')
df.head()
fig = go.Figure(data=go.Choropleth(
locations = df['code'], # spatial co-ordinates
z = df['total exports'].astype(float), # Data to be color-coded
locationmode = 'USA-states', # set of location match entries in 'locations'
colorscale= 'reds',
colorbar_title = "Millions USD"
))
fig.update_layout(
title_text = '2011 US Agriculture Exports by State',
geo_scope = 'usa')
fig.show()
fig = go.Figure(data=go.Choropleth(
locations=['TX','CA','NY'], # spatial co-ordinates
z = [1.0,2.0,3.0], # Data to be color-coded
locationmode = 'USA-states', # set of location match entries in 'locations'
colorscale= 'portland',
text=['t1','t2','t3']
))
fig.update_layout(
title_text = 'Three states study',
geo_scope = 'usa')
fig.show()
df = pd.read_csv('data/2014_World_GDP')
df.head()
fig = go.Figure(data=go.Choropleth(
locations = df['CODE'], # spatial co-ordinates
z = df['GDP (BILLIONS)'], # Data to be color-coded
colorscale= 'reds',
colorbar_title = "GDP BILLIONS US$"
))
fig.update_layout(
title_text = 'World GDP study',
geo= dict(
showframe=True,
showcoastlines=False,
projection_type='equirectangular'
))
fig.show()